package com.rd.student.ruanjian.class1.duhang.NewNew0803;

import java.util.ArrayList;
import java.util.Scanner;

public class Array {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        ArrayList<Animal> list = new ArrayList<>();

        String[] animal = {"小黄", "大黄", "二黄", "三皇", "四皇", "吾皇", "硫磺", "七煌",
                "八荒", "韭黄", "小苗", "二喵", "三秒", "思淼", "呜喵", "葫芦", "哈罗", "小粉",};
        String[] putcolor = {"黄色的", "白色的", "黑色的", "灰色的"};
        String[] eyecolor = {"蓝色的", "黑色的", "绿色的"};

        for (int i = 0; i < 10; i++) {
            int index = (int) (Math.random() * putcolor.length);
            list.add(new Dog(animal[i], putcolor[index]));
        }
        for (int i = 10; i < 15; i++) {
            int index0 = (int) (Math.random() * eyecolor.length);
            list.add(new Cat(animal[i], eyecolor[index0]));
        }
        for (int i = 15; i < 18; i++) {
            list.add(new Pig(animal[i]));
        }

        int random = (int) (Math.random() * list.size());

        System.out.println(list.get(random));

        System.out.println("------------------");


        System.out.println("欢迎光临！！！ 本店宠物有：小狗，小猫，小猪");

        System.out.println("-------------------");
        boolean a = true;
        while (a) {
            System.out.println("请您选择：");
            System.out.println("1.随便看看");
            System.out.println("2.选择购买宠物");

            switch (scanner.nextInt()) {

                case 1:
                    int random00 = (int) ((Math.random() + 1) * list.size());
                    for (int i = 0; i < random00; i++) {
                        int random01 = (int) (Math.random() * list.size());
                        System.out.println(list.get(random01));
                        list.get(random01).enjoy();
                    }
                    break;
                case 2:
                    System.out.println("请选择您的宠物种类：");
                    System.out.println("1.小狗");
                    System.out.println("2.小猫");
                    System.out.println("3.小猪");
                    switch (scanner.nextInt()) {
                        case 1:
                            for (int i = 0; i < 10; i++) {
                                System.out.println(list.get(i));
                            }
                            System.out.println("-------------");
                            System.out.println("选择您的小狗");
                            int n = scanner.nextInt() - 1;
                            System.out.print("您选择的宠物名字是" + list.get(n).getName() + "   ");
                            list.get(n).voice();
                            list.get(n).enjoy();
                            break;

                        case 2:
                            for (int i = 10; i < 15; i++) {
                                System.out.println(list.get(i));
                            }
                            System.out.println("-------------");
                            System.out.println("选择您的小猫");
                            int n1 = scanner.nextInt();
                            System.out.print("您选择的宠物名字是" + list.get(n1 + 9).getName() + "   ");
                            list.get(n1 + 9).voice();
                            list.get(n1 + 9).enjoy();
                            break;

                        case 3:
                            for (int i = 15; i < list.size(); i++) {
                                System.out.println(list.get(i));
                            }
                            System.out.println("-------------");
                            System.out.println("选择您的小猪");
                            int n2 = scanner.nextInt();
                            System.out.print("您选择的宠物名字是" + list.get(n2 + 14).getName() + "   ");
                            list.get(n2 + 14).voice();
                            list.get(n2 + 14).enjoy();
                            break;
                    }
                    System.out.println("请您慢走，欢迎下次光临！！！");
                    a = false;
            }
        }
    }
}

abstract class Animal {

    String name;

    public void voice() {

    }

    public Animal(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public abstract void enjoy();
}


class Dog extends Animal {
    String putColor;

    public Dog(String name, String putColor) {
        super(name);
        this.putColor = putColor;
    }

    public String getPutColor() {
        return putColor;
    }

    public void setPutColor(String putColor) {
        this.putColor = putColor;
    }

    @Override
    public String toString() {
        return "小狗" +
                "名字叫" + name +
                "皮毛是" + putColor;
    }

    @Override
    public void voice() {
        System.out.println(getName() + "叫一叫");
    }


    @Override
    public void enjoy() {
        String[] enjoyy = {"摇尾巴", "叫了叫", "舒服的趴着", "跑到你的面前",};
        int random = (int) (Math.random() * enjoyy.length);
        System.out.println(name + enjoyy[random]);
    }
}

class Cat extends Animal {
    String eyeColor;

    public Cat(String name, String eyeColor) {
        super(name);
        this.eyeColor = eyeColor;
    }

    public String getEyeColor() {
        return eyeColor;
    }

    public void setEyeColor(String eyeColor) {
        this.eyeColor = eyeColor;
    }

    @Override
    public String toString() {
        return "小猫" +
                "名字是" + name +
                ", 眼睛是" + eyeColor;
    }

    @Override
    public void voice() {
        System.out.println(getName() + "笑一笑 , " + getName() + "有" + eyeColor + "眼睛");
    }


    @Override
    public void enjoy() {
        String[] enjoy = {"喵喵的叫", "伸懒腰", "舒服的趴着", "在你腿上蹭",};
        int random = (int) (Math.random() * enjoy.length);
        System.out.println(name + enjoy[random]);
    }
}

class Pig extends Animal {

    public Pig(String name) {
        super(name);
    }

    @Override
    public void voice() {
        System.out.println(getName() + "呼呼大睡");
    }

    @Override
    public void enjoy() {
        System.out.println(name + "呼呼");
    }

    @Override
    public String toString() {
        return "小猪" +
                "名字是" + name;
    }
}

class Lady {
    String name;
    Animal pet;

    public Lady(String name, Animal pet) {
        this.name = name;
        this.pet = pet;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Animal getPet() {
        return pet;
    }

    public void setPet(Animal pet) {
        this.pet = pet;
    }

    @Override
    public String toString() {
        return "Lady{" +
                "name='" + name + '\'' +
                ", pet=" + pet +
                '}';
    }

    public void myPetEnjoy() {
        pet.voice();
    }
}



